#ifndef IBOX_CONNECTION_H_INCLUDED
#define IBOX_CONNECTION_H_INCLUDED

#include <Core/Commands.h>

#include <exception>
#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>

namespace Core { namespace BoxApi {

/** Box connection parameters
 *  Structure conectains Server connection params
 */
struct BoxConnectionParams {
	std::string host;
	std::string port;
	std::string name;
	int id;
};

/**  Box connection abstracation provides interface for server connection
 *
 */
class IBoxConnection : boost::noncopyable {
public :
	explicit IBoxConnection(BoxConnectionParams const & params) { }
	virtual ~IBoxConnection() { }
	
	/** Establish connection with server 
	 *  @trow std::exception
	 * 		if connnection is not established 
	 */
	virtual void establishConnection() throw (std::exception) = 0;
	
	/** Close connection 
	 * 	 
	 */
	virtual void close() throw () = 0;
	
	/** Gets unique connection id
	 * 	 
	 */
	virtual int getConnectionId() const throw (std::exception) = 0;
	
	/** Send connection synchroniously
	 * It return s after responce receiving	 
	 */
	virtual ICommandPtr sendMessageSync(ICommandPtr command) = 0;
	
	/** Write raw data to connection
	 *  It is used for data arrays sending
	 * @return 
	 * 		sent bytes count
	 * 		0 - if any error occurred
	 */
	virtual std::size_t writeRawData(std::vector<boost::uint8_t> const & data) throw() = 0;

private :

};

typedef boost::shared_ptr<IBoxConnection> IBoxConnectionPtr;

} } // namespace Core, BoxApi

#endif

